#include "doublelist.h"

int main(void)
{
	/*创建空链表*/
	pnode head = creat_doublelist();
	
	/*向链表中插入若干节点*/
	int i,n;
	pnode ppre,pnew;//插入节点的前置节点的指针，插入节点的指针
	ppre = head;//初始化前置节点的位置
	printf("请输入要插入的节点个数：");
	scanf("%d",&n);
	for (i = 0;i < n;i++)
	{
		pnew = (pnode)malloc(sizeof(NODE));
		if (pnew == NULL) 
		{
			perror("malloc");
			return 1;			
		}
		
		printf("请输入第%d个整数：",i+1);
		scanf("%d",&(pnew->data));
		insert_node(ppre,pnew);
		ppre = ppre->next;
		print_doublelist(head);
	}
	
	/*删除某一节点*/
	//delete(head,3);
	//print_doublelist(head);
	
	/*翻转链表*/
	//reverse_doublelist(head);
	//print_doublelist(head);
	
	/*奇偶排序（奇数升序在前，偶数降序在后）*/
	//sort_oddeven(head);
	//print_doublelist(head);
	
	/*排序（从小到大）*/
	sort_doublelist(head);
	print_doublelist(head);
	
	return 0;
}